<?php
	include './header.php';
	$sql_goods="select
					g.id        gid,
					g.name      gname,
					g.is_new    gnew,
					g.is_bast   gbast,
					g.price     gp,
					gi.name     giname
				from
					goods       g,
					goods_img   gi
				where
					g.id=gi.goods_id
				and
					gi.is_cover=1
				and
					g.is_bast=1
				";
	$new=[];
	$goods_list=$goods_model->find($sql_goods);
	if (!empty($goods_list)) 
	{
		foreach ($goods_list as $k => $v) 
		{
			
			if ($v['gnew']==1) 
			{
				$new[]=$v;
			}
		}
	}
	if (!empty($new)) 
	{
		foreach ($new as $key => $value) 
		{
			$new[$key]['giname']=URL.'/public/uploads/'.substr($value['giname'], 0,4).'/'.substr($value['giname'], 4,2).'/'.substr($value['giname'], 6,2).'/300_'.$value['giname'];
		}
	}
	
?>
<div class="clear"></div>
<div id="main">
	<!--遍历新品图片-->
	<div class="new_nav">
		<span>新品上市</span>
	</div>
	<div class="new_n">
		<?php if (!empty($new)) :?>
			
			<ul>
				<?php foreach ($new as $n => $va) :?>
					<div class="ji">
					<li>
					<a href="<?php echo URL;?>/detail.php?id=<?php echo $va['gid'];?>">
					<img src="<?php echo $va['giname'];?>" alt="美工回家生娃了" ><br/>
					<span style="color:#000;"><?php echo $va['gname'];?></span></a><br/>
					<span style="color:red;">¥:<?php echo $va['gp'];?></span>
					</li>
						</div>
				<?php endforeach;?>
			</ul>
		
		<?php else :?>
			<div>没有新品上架</div>
		<?php endif;?>
	</div>
	<div class="clear"></div>
	
</div>

<?php 
	include PATH.'/footer.php';
?>